package cn.edu.zknu.mita.service.impl;

import cn.edu.zknu.mita.mapper.FindMsgMapper;
import cn.edu.zknu.mita.mapper.FindWallMapper;
import cn.edu.zknu.mita.model.FindImage;
import cn.edu.zknu.mita.service.IFindWallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by iwlnner on 2020/4/5.
 */
@Service
public class FindWallService implements IFindWallService {

    @Autowired
    private FindWallMapper findWallMapper;
    @Autowired
    private FindMsgMapper findMsgMapper;

    @Override
    public Integer saveImg(FindImage findImage) {
        return findWallMapper.saveImg(findImage);
    }

    public FindImage checkExistImage(Long userId){
        return findWallMapper.queryImgByUserId(userId);
    }


    public List<FindImage> listWallMsg(){
        return findWallMapper.listWallFindImg();
    }

    /*public List<WallVO> listWallMsg(){
        List<FindImage> findImages = findWallMapper.listWallFindImg();
        List<String> titles = findMsgMapper.listTitleByFindImage(findImages);
        List<WallVO> walls=new ArrayList<>();
        for(int i=0;i<findImages.size();i++){
            WallVO wall=new WallVO();
            wall.setImage(findImages.get(i).getUrl());
            wall.setId(findImages.get(i).getFindMsgId());
            wall.setTitle(titles.get(i));
            walls.add(wall);
        }
        return walls;
    }*/

    public Integer deleteFindImg(Long findMsgId){
        return findWallMapper.deleteFindImg(findMsgId);
    }
}
